package com.wdh.kjs.activity;

import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.wdh.kjs.R;
import com.wdh.kjs.fragment.Mf_finance_Fragment;
import com.wdh.kjs.fragment.Mf_investment_Fragment;
import com.wdh.kjs.fragment.Mf_rechargewithdraw_Fragment;


/**
 * Created by CQH on 2016/4/21.
 */
public class MoneyFlowingActivity extends BaseTopActivity implements View.OnClickListener {
    private TextView bt_id_investment_flowing;
    private TextView bt_id_finance_flowing;
    private TextView bt_id_recharge_withdraw;
    private FragmentManager manager;
    private FragmentTransaction transaction;
    private Mf_investment_Fragment fragmentOne;
    private Mf_finance_Fragment fragmentTwo;
    private Mf_rechargewithdraw_Fragment fragmentThree;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fragment_moneyflowing);
        initTopBar("资金流水");
        initView();
    }

    public void initView(){
        bt_id_investment_flowing = (TextView)findViewById(R.id.bt_id_investment_flowing);
        bt_id_finance_flowing = (TextView)findViewById(R.id.bt_id_finance_flowing);
        bt_id_recharge_withdraw = (TextView)findViewById(R.id.bt_id_recharge_withdraw);
//        Log.i("msg","hahaha3");

        bt_id_investment_flowing.setOnClickListener(this);
        bt_id_finance_flowing.setOnClickListener(this);
        bt_id_recharge_withdraw.setOnClickListener(this);
        Log.i("msg","hahaha2");

        manager=getFragmentManager();
        transaction=manager.beginTransaction();
        fragmentOne=new Mf_investment_Fragment();
        transaction.add(R.id.mf_id_list, fragmentOne);
        transaction.commit();
        bt_id_investment_flowing.setTextColor(getResources().getColor(R.color.blue_light));
        Log.i("msg","hahaha1");

    }

    @Override
    public void onClick(View view) {
        transaction=manager.beginTransaction();
        switch (view.getId())
        {
            case R.id.bt_id_investment_flowing:
                bt_id_investment_flowing.setTextColor(getResources().getColor(R.color.blue_light));
                bt_id_finance_flowing.setTextColor(getResources().getColor(R.color.text_color));
                bt_id_recharge_withdraw.setTextColor(getResources().getColor(R.color.text_color));
                fragmentOne=new Mf_investment_Fragment();
                transaction.replace(R.id.mf_id_list, fragmentOne, "fragmentOne");
                transaction.addToBackStack("fragmentOne");
                break;
            case R.id.bt_id_finance_flowing:
                bt_id_investment_flowing.setTextColor(getResources().getColor(R.color.text_color));
                bt_id_finance_flowing.setTextColor(getResources().getColor(R.color.blue_light));
                bt_id_recharge_withdraw.setTextColor(getResources().getColor(R.color.text_color));
                fragmentTwo=new Mf_finance_Fragment();
                transaction.replace(R.id.mf_id_list, fragmentTwo, "fragmentTwo");
                transaction.addToBackStack("fragmentTwo");
                break;
            case R.id.bt_id_recharge_withdraw:
                bt_id_investment_flowing.setTextColor(getResources().getColor(R.color.text_color));
                bt_id_finance_flowing.setTextColor(getResources().getColor(R.color.text_color));
                bt_id_recharge_withdraw.setTextColor(getResources().getColor(R.color.blue_light));
                fragmentThree=new Mf_rechargewithdraw_Fragment();
                transaction.replace(R.id.mf_id_list, fragmentThree, "fragmentThree");
                transaction.addToBackStack("fragmentThree");
                break;
        }
        transaction.commit();
    }
}
